package org.jadapter.tests.examples;

import java.util.List;
import java.util.Map;

public class AmbiguousAdapter implements Csv {

        private Map<?,?> map;

        public AmbiguousAdapter(List ambiguous) {
            // this would be a bad constructor
        }
        
        public AmbiguousAdapter(Map<?,?> map) {
            this.map = map;
        }

        public String csv() {        
            if(map == null) 
                return "";                  
            StringBuilder buffer = new StringBuilder();
            
            for(Object key : map.keySet()) 
                buffer.append(key + ":" + map.get(key) + ",");
            if(map.size() > 0)
                buffer.deleteCharAt(buffer.length() - 1);
            return buffer.toString();
        }   
    
}
